﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using NHibernate.Driver;

namespace Dexter.Repository.NHibernate.Drivers {
	public class DexterSqlClientDriver : SqlClientDriver {
		
		public override void AdjustCommand ( System.Data.IDbCommand command ) {
			foreach (var parameter in command.Parameters.Cast<SqlParameter> ( ).Where ( x => x.SqlDbType == SqlDbType.DateTime && ( x.Value is DateTime ) )) {
				var dateTimeValue = (( DateTime )parameter.Value).ToUniversalTime (  );
				parameter.Value = dateTimeValue;
			}
		}
	}
}
